package com.briup.mt.service.impl;

import com.briup.mt.bean.BasePrivilege;
import com.briup.mt.bean.BasePrivilegeExample;
import com.briup.mt.dao.BasePrivilegeMapper;
import com.briup.mt.service.BasePrivilegeService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;





@Service
public class BasePrivilegeImpl implements BasePrivilegeService {
    @Resource
    private BasePrivilegeMapper basePrivilegeMapper;

    @Override
    public List<BasePrivilege> query(String name) {
        BasePrivilegeExample basePrivilegeExample=new BasePrivilegeExample();
        if(!StringUtils.isEmpty(name)){
            basePrivilegeExample.createCriteria().andNameLike("%"+name+"%");
        }

        List<BasePrivilege>list=basePrivilegeMapper.selectByExample(basePrivilegeExample);
        return list;
    }

    @Override
    public void saveOrUpdate(BasePrivilege basePrivilege) {
        if (basePrivilege.getId() == null) {
            basePrivilegeMapper.insert(basePrivilege);
        } else {
            basePrivilegeMapper.updateByPrimaryKey(basePrivilege);
        }
    }
    @Override
    public void deleteById(long id) {
          basePrivilegeMapper.deleteByPrimaryKey(id);
    }
}
